package main

import (
    "fmt"
    "time"
)
//子goroutine
func newTask(){
    i := 0
    for {
        i++
        fmt.Printf("new Goroutine : i = %d\n",i)
        time.Sleep(1 * time.Second)
    }
}

//主goroutine
func main(){
    //创建一个go协程
    go newTask()

    //主进程退出，整个进程退出
    fmt.Println("main goroutine exit")

    /*
    i := 0
    for {
        i++
        fmt.Printf("main goroutine : i = %d\n",i)
        time.Sleep(1 * time.Second)
    }*/
}